package com.topisv.tms.utils.sf;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class TestBspExpressServlet {

	public static void main(String[] args) throws Exception {
		//定义参数 begin
		String uri="http://10.0.78.9/bsp-oisp/sfexpressService";
		String xmlFile="D:\\JavaDev\\workspace\\BSP-TEST\\src\\xml.txt";
		String checkWord="j8DzkIFgmlomPt0aLuwU";
		//定义参数 end
		URL url = new URL(uri);
		String xml = Util.loadFile(xmlFile);
		String verifyCode = Util.md5EncryptAndBase64(xml + checkWord);
		
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		conn.setRequestMethod("POST");
		conn.setDoOutput(true);
		conn.setConnectTimeout(10000);
		conn.setReadTimeout(10000);
		
		OutputStream os = conn.getOutputStream();
		os.write(("xml=" + xml + "&verifyCode=" + verifyCode).getBytes("utf8"));
		os.close();

		InputStream in = conn.getInputStream();
		byte[] data = new byte[in.available()];
		in.read(data);
		System.out.println(new String(data, "utf8").replace("><", ">\n<"));
	}

}
